<wxs module="dateFr" src="../../js/filter.wxs"></wxs>
<view>
        <import src="../detail/detail" />
        <template is="{{template}}" data="{{my_toast_tip: my_toast_tip}}" />
    <view >
            <view class="order_header">
                <view bindtap="switchNav" data-current="0" class="tab {{currentTab==0?'active':''}}">
                    <view>全部</view>
                </view>
                <view bindtap="switchNav" data-current="1" class="tab {{currentTab==1?'active':''}}">
                    <view>待付款</view>
                </view>
                <view bindtap="switchNav" data-current="2" class="tab {{currentTab==2?'active':''}}">
                    <view>已完成</view>
                </view>
            </view>
            <swiper class="tab-content" current="{{currentSwiper}}" duration="300" bindchange="switchTab" style="height:{{winHeight}}rpx">
                <!-- 全部订单 -->
                <swiper-item>
                    <scroll-view scroll-y="true" class="scoll-h" bindscrolltolower="lower" data-status="100" data-list="allList">
                        <block wx:for="{{allList.list}}" wx:key="1">
                            <view class="order">
                                <view class="order_code">订单编号:{{item.orderCode}}
                                <span bindtap='callOwers' data-code="{{item.shopCode}}" wx:if="{{item.reserveType==2}}"><image src="../../img/icon_phone.png"></image>联系店主</span>
                                </view>
                                <navigator  class="navigator" url="{{item.urlSrt}}" hover-class="none">
                                    <scroll-view class="img_container" scroll-x scroll-top="0" scroll-left="0" style="width:80%">
                                        <view class="img_view" wx:for="{{item.orderGoods}}" wx:for-item="goodList" wx:key="*this">
                                            <image wx:if="{{goodList.imagePath}}" src="{{goodList.imagePath}}"></image>
                                            <image wx:else src="{{imageUrl}}/xiaomai.jpg"></image>
                                            <label wx:if="{{goodList.num>1}}">x{{goodList.num}}</label>
                                        </view>
                                    </scroll-view>
                                    <view class="rightContent">
                                            <view>总价:￥{{util.formatNum(item.originalPrice)}}</view>
                                            <view class="red">
                                                <text wx:if="{{item.status==0}}">待付</text>
                                                <text wx:elif="{{item.status==2}}">实付</text>
                                                <text wx:else>应付</text>
                                                ￥{{util.formatNum(item.price)}}
                                            </view>
                                        <view class="total_num">共{{item.num}}件</view>
                                    </view>
                                </navigator>
                              
                                <view class="order_footer">
                                    <view class="left">
                                        {{util.formatDate(item.createDate)}}
                                    </view>
                                    <view class="right">
                                        <view class="status" wx:if="{{item.status==2}}">已完成</view>
                                        <navigator bindtap="goToPay" wx:elif="{{item.status==0}}" class="pre_pay" url="{{item.payUrlSrt}}" hover-class="navigator-hover">待付款</navigator>
                                         <view class="status"  wx:elif="{{item.status==7}}">待收货</view>
                                         <view class="status" wx:else>已取消</view>
                                    </view>
                                </view>
                            </view>
                        </block>
                        <view class="loadingText" wx:if="{{allList.list.length>0}}">
                            <image wx:if="{{!allList.isLast}}" class="loading" src="{{imageUrl}}/loading.png"></image>
                            <view class="text">{{allList.isLast?"您已经没有更多订单了":"数据加载中..."}}</view>
                        </view>
                        <view wx:else class="empty_container">
                            <image class='empty_img' src="{{imageUrl}}/empty_order.png"></image>
                    
                            <view class="p1">空空的</view>
                            <view class="p2">快选几件好物放进来</view>
                    
                            <navigator wx:if="{{shopCode}}" url="../scan/scan" hover-class="none"><view class="select_btn">先去挑选商品</view></navigator>
                            <navigator wx:else open-type='switchTab' url="../index/index" hover-class="none"><view class="select_btn">先去挑选商品</view></navigator>
                            
                        </view>
                    </scroll-view>
                </swiper-item>
                <!-- 待付款订单 -->
                <swiper-item>
                    <scroll-view scroll-y="true" class="scoll-h" bindscrolltolower="lower" data-status="0" data-list="unpayList">
                        <block wx:for="{{unpayList.list}}" wx:key="2">
                            <view class="order">
                                <view class="order_code">订单编号:{{item.orderCode}}
                                 <span bindtap='callOwers' data-code="{{item.shopCode}}" wx:if="{{item.reserveType==2}}"><image src="../../img/icon_phone.png"></image>联系店主</span></view>
                                <navigator class="navigator" url="{{item.urlSrt}}" hover-class="none">
                                    <scroll-view class="img_container" scroll-x scroll-top="0" scroll-left="0" style="width:80%">
                                        <view class="img_view" wx:for="{{item.orderGoods}}" wx:for-item="goodList" wx:key="*this">
                                            <image wx:if="{{goodList.imagePath}}" src="{{goodList.imagePath}}"></image>
                                            <image wx:else src="{{imageUrl}}/xiaomai.jpg"></image>
                                            <label wx:if="{{goodList.num>1}}">x{{goodList.num}}</label>
                                        </view>
                                    </scroll-view>
                                    <!-- <view class="total_num">共{{item.num}}件</view> -->
                                    <view class="rightContent">
                                        <view>总价:￥{{util.formatNum(item.originalPrice)}}</view>
                                        <view class="red">
                                            <text wx:if="{{item.status==0}}">待付</text>
                                            ￥{{util.formatNum(item.price)}}
                                        </view>
                                    <view class="total_num">共{{item.num}}件</view>
                                </view>
                                </navigator>
                                <view class="order_footer">
                                    <view class="left">
                                        <!-- <view>总价:￥{{util.formatNum(item.originalPrice)}}</view>
                                        <view class="red">
                                            <text wx:if="{{item.status==0}}">待付</text>
                                            ￥{{util.formatNum(item.price)}}
                                        </view> -->
                                        {{util.formatDate(item.createDate)}}
                                    </view>
                                    <view class="right">
                                        <navigator bindtap="goToPay" class="pre_pay" url="{{item.payUrlSrt}}" hover-class="navigator-hover">待付款</navigator>
                                    </view>
                                </view>
                            </view>
                        </block>
                        <view class="loadingText" wx:if="{{unpayList.list.length>0}}">
                            <image wx:if="{{!unpayList.isLast}}" class="loading" src="{{imageUrl}}/loading.png"></image>
                            <view class="text">{{unpayList.isLast?"您已经没有更多订单了":"数据加载中..."}}</view>
                        </view>
                       
                        <view wx:else class="empty_container">
                            <image class='empty_img' src="{{imageUrl}}/empty_order.png"></image>
                    
                            <view class="p1">空空的</view>
                            <view class="p2">快选几件好物放进来</view>
                    
                            <navigator wx:if="{{shopCode}}" url="../scan/scan" hover-class="none"><view class="select_btn">先去挑选商品</view></navigator>
                            <navigator wx:else open-type='switchTab' url="../index/index" hover-class="none"><view class="select_btn">先去挑选商品</view></navigator>
                            
                        </view>
    
                        <!-- <image class='empty_img' wx:else src="{{imageUrl}}/empty_order.png"></image> -->
                    </scroll-view>
                </swiper-item>
                <!-- 已完成订单 -->
                <swiper-item>
                    <scroll-view scroll-y="true" class="scoll-h" bindscrolltolower="lower" data-status="2" data-list="succList">
                        <block wx:for="{{succList.list}}" wx:key="3">
                            <view class="order" wx:if="{{item.status==2}}">
                                <view class="order_code">订单编号:{{item.orderCode}}<span bindtap='callOwers' data-code="{{item.shopCode}}" wx:if="{{item.reserveType==2}}"><image src="../../img/icon_phone.png"></image>联系店主</span></view>
                                <navigator class="navigator" url="{{item.urlSrt}}" hover-class="none">
                                    <scroll-view class="img_container" scroll-x scroll-top="0" scroll-left="0" style="width:80%">
                                        <view class="img_view" wx:for="{{item.orderGoods}}" wx:for-item="goodList" wx:key="*this">
                                            <image wx:if="{{goodList.imagePath}}" src="{{goodList.imagePath}}"></image>
                                            <image wx:else src="{{imageUrl}}/xiaomai.jpg"></image>
                                            <label wx:if="{{goodList.num>1}}">x{{goodList.num}}</label>
                                        </view>
                                    </scroll-view>
                                    <view class="rightContent">
                                        <view>总价:￥{{util.formatNum(item.originalPrice)}}</view>
                                        <view class="red">
                                            <text wx:if="{{item.status==2}}">实付</text>
                                            ￥{{util.formatNum(item.price)}}
                                        </view>
                                    <view class="total_num">共{{item.num}}件</view>
                                </view>
                                </navigator>
                                <view class="order_footer">
                                    <view class="left">
                                        <!-- <view>总价:￥{{util.formatNum(item.originalPrice)}}</view>
                                        <view class="red">
                                            <text wx:if="{{item.status==2}}">实付</text>
                                            ￥{{util.formatNum(item.price)}}
                                        </view> -->
                                        {{util.formatDate(item.createDate)}}
                                    </view>
                                    <view class="right">
                                        <view class="status" wx:if="{{item.status==2}}">已完成</view>
                                    </view>
                                </view>
                            </view>
                        </block>
                        <view class="loadingText" wx:if="{{succList.list.length>0}}">
                            <image wx:if="{{!succList.isLast}}" class="loading" src="{{imageUrl}}/loading.png"></image>
                            <view class="text">{{succList.isLast?"您已经没有更多订单了":"数据加载中..."}}</view>
                        </view>
                        <view wx:else class="empty_container">
                            <image class='empty_img' src="{{imageUrl}}/empty_order.png"></image>
                    
                            <view class="p1">空空的</view>
                            <view class="p2">快选几件好物放进来</view>
                    
                            <navigator wx:if="{{shopCode}}" url="../scan/scan" hover-class="none"><view class="select_btn">先去挑选商品</view></navigator>
                            <navigator wx:else open-type='switchTab' url="../index/index" hover-class="none"><view class="select_btn">先去挑选商品</view></navigator>
                            
                        </view>
                    </scroll-view>
                </swiper-item>
            </swiper>
        </view>

</view>

<wxs module="util"> 
        var formatNum=function(n){ 
            return Number(n) 
        } 
        var formatNumber =function(n){
            n = n.toString()
            return n[1] ? n : '0' + n
          }
        var formatDate=function(millisecond){
            var  date=getDate(millisecond),
             year = date.getFullYear(),
             month = date.getMonth() + 1,
             day = date.getDate(),
             hour = date.getHours(),
             minute = date.getMinutes(),
             second = date.getSeconds();
            return [year, month, day].map(formatNumber).join('-') + '   '+' ' + [hour, minute].map(formatNumber).join(':')
        } 
        module.exports = { 
            formatNum : formatNum, 
            formatDate:formatDate
        }
</wxs>